<!--
 * @Date: 2022-01-08 16:52:29
 * @LastEditors: 邓春宜
 * @Desc: 
 * @LastEditTime: 2022-01-18 11:22:45
 * @FilePath: \web-ems\src\view\sys\dic\modal\info.vue
-->
<template>
 <a-modal
    :visible="visible"
    :title="t('info')"
    :cancelText="t('cancel')"
    :okText="t('submit')"
    @ok="submit"
    @cancel="cancel(false)"
  >
    <a-form
       ref="formRef"
      :model="formState" 
      :label-col="labelCol"
      :wrapper-col="wrapperCol"
    >
    <a-form-item ref="name" :label="t('name')" name="name"><a-input readonly v-model:value="formState.name" /> </a-form-item>
<a-form-item ref="desc" :label="t('desc')" name="desc"><a-textarea readonly v-model:value="formState.desc" /> </a-form-item>
<a-form-item ref="value" :label="t('value')" name="value"><a-textarea readonly v-model:value="formState.value" /> </a-form-item>
<a-form-item ref="field1" :label="t('field1')" name="field1"><a-input readonly v-model:value="formState.field1" /> </a-form-item>
<a-form-item ref="field2" :label="t('field2')" name="field2"><a-input readonly v-model:value="formState.field2" /> </a-form-item>
<a-form-item ref="field3" :label="t('field3')" name="field3"><a-input readonly v-model:value="formState.field3" /> </a-form-item>
<a-form-item ref="field4" :label="t('field4')" name="field4"><a-input readonly v-model:value="formState.field4" /> </a-form-item>
<a-form-item ref="field5" :label="t('field5')" name="field5"><a-input readonly v-model:value="formState.field5" /> </a-form-item>
    </a-form>
  </a-modal>
</template>
<script>
import { useI18n  } from "vue-i18n";
import { message } from 'ant-design-vue'; 
import { defineComponent, reactive, ref, toRaw, watch } from "vue";
export default defineComponent({
  props: {
    visible: {
      type: Boolean,
    },
    record: {
      type: Object
    }
  },
  emit: ["close"],
  setup(props, context) {
    const { t } = useI18n();
    const state = reactive({ 
      depts: [], 
    })
    
    const formRef = ref();
    
    const formState = reactive({
      sort: 0,
      enable: true,
    });

    watch(props,(props) => {
formState.id = props.record.id;
formState.name = props.record.name;
formState.desc = props.record.desc;
formState.value = props.record.value;
formState.field1 = props.record.field1;
formState.field2 = props.record.field2;
formState.field3 = props.record.field3;
formState.field4 = props.record.field4;
formState.field5 = props.record.field5;
    })

    

    const submit = (e) => {
      formRef.value.resetFields();
      context.emit("close", false);
    };

    const cancel = (e) => {
      formRef.value.resetFields();
      context.emit("close", false);
    };

  

    return {
      t,
      state,
      submit,
      cancel,
      formRef,
      formState, 
      labelCol: { span: 6 },
      wrapperCol: { span: 18 }, 
    };
  },
});
</script>